﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework.Constraints;

namespace TimScripts.BF4Rcon.Test
{
    public class PlayerSubsetTests
    {
        [Test]
        public void AllCtorSetsCorrectType()
        {
            PlayerSubset subset = PlayerSubset.CreateAll();

            Assert.AreEqual(PlayerSubsetType.All, subset.SubsetType);
        }

        [Test]
        public void TeamCtorSetsCorrectType()
        {
            PlayerSubset subset = PlayerSubset.CreateTeam(1);

            Assert.AreEqual(PlayerSubsetType.Team, subset.SubsetType);
        }

        [Test]
        public void SquadCtorSetsCorrectType()
        {
            PlayerSubset subset = PlayerSubset.CreateSquad(1, 1);

            Assert.AreEqual(PlayerSubsetType.Squad, subset.SubsetType);
        }

        [Test]
        public void PlayerCtorSetsCorrectType()
        {
            PlayerSubset subset = PlayerSubset.CreatePlayer((Player)null);

            Assert.AreEqual(PlayerSubsetType.Player, subset.SubsetType);
        }

        [Test]
        public void AllBlocksAllProperties()
        {
            PlayerSubset subset = PlayerSubset.CreateAll();

            Assert.Throws<InvalidOperationException>(() => { var x = subset.Player; });
            Assert.Throws<InvalidOperationException>(() => { var x = subset.TeamId; });
            Assert.Throws<InvalidOperationException>(() => { var x = subset.SquadId; });
        }

        [Test]
        public void TeamOnlyAllowsTeam()
        {
            PlayerSubset subset = PlayerSubset.CreateTeam(1);

            Assert.Throws<InvalidOperationException>(() => { var x = subset.Player; });
            Assert.Throws<InvalidOperationException>(() => { var x = subset.SquadId; });
        }

        [Test]
        public void SquadOnlyAllowsTeamAndSquad()
        {
            PlayerSubset subset = PlayerSubset.CreateSquad(1, 1);

            Assert.Throws<InvalidOperationException>(() => { var x = subset.Player; });
        }
    }
}
